Output
Structured output for generateText / streamText / Agent.
Per invariant I-3 / I-6, structured output goes through Output. Prefer generateText(output = ...) / streamText(output = ...). generateObject() and streamObject() are compatibility shims for v6 call sites that still use the deprecated object helpers.
Four variants:
Obj — single typed object (Kotlin-keyword-safe rename of v6's
object).Arr — array of typed objects.
Choice — constrained enum / set of allowed string values.
JsonTree — generic JSON tree, untyped.
Idiomatic use:
val recipe = generateText(
model = ...,
prompt = "Generate a chocolate cake recipe",
output = Output.obj(serializer<Recipe>()),
).outputContent copied to clipboard